<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="passwordModalLabel">更改密码</h4>
</div>
<div class="modal-body">
    <form id="person">
    <div class="form-group input-group  input-control">
        <span class="input-group-addon">&nbsp;&nbsp;原密码&nbsp;</span>
        <input type="password" class="form-control" name="passold" placeholder="" id="passold" value="">
    </div>
    <div class="form-group input-group  input-control">
        <span class="input-group-addon">&nbsp;&nbsp;新密码&nbsp;</span>
        <input type="password" class="form-control" name="passnew" placeholder="" id="passnew" value="">
    </div>
    <div class="form-group input-group  input-control">
        <span class="input-group-addon">确认密码</span>
        <input type="password" class="form-control" name="passconfirm" placeholder="" id="passconfirm" value="">
    </div>
    </form>
</div>
<div class="modal-footer">
    <span class="tips" id="patip"></span>
    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    <button type="button" class="btn btn-primary" id="passwordedit">确认</button>
</div>
<script>
$(document).ready(function() {
    $('#passwordedit').click(function() {
        if (isNull2("原密码", "passold")) {
            return;
        }
        if (isNull2("新密码", "passnew")) {
            return;
        }
        if(!/^\w{6,18}$/.test($('#passnew').val().trim())) {
            $('#patip').html('密码仅允许是6~18位字母、数字和下划线');
            return;
        }
        if (isNull2("确认密码", "passconfirm")) {
            return;
        }
        if($('#passnew').val() !== $('#passconfirm').val()) {
            $('#patip').html('确认密码不一致');
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"<?php echo APP_ADMIN_PATH; ?>/user/resetpassword",
            data:$('#person').serialize(),
            dataType: 'json',
            error: function(data) {
                alert('系统异常，请稍后再试！');
            },
            success: function(data) {
                alert(data.msg);
                if(data.retcode == 2000000) {
                    refresh();
                }
            }
        });
    });
});
</script>
